package com.intretech.umsin.oss.config;

import com.intretech.umsin.oss.util.SftpOssClient;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @ClassName: SftpOSSConfig
 * @Description: SftpOSSConfig 服务实现
 * @author: 李启联
 * @date: 2022-04-25 22:55
 * @Copyright: Copyright (c) 2022
 */
@Configuration
@ConfigurationProperties(ignoreUnknownFields = true, prefix = "sftp.oss")
@ConditionalOnProperty(name = "oss-type",havingValue = "SFTP",matchIfMissing = false)
public class SftpOSSConfig {


    private String host;

    private int port;

    private String username;

    private String password;

    private String workDir;

    private String privateKey;

    private String privateKeyPassword;

    private String domain ;

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getWorkDir() {
        return workDir;
    }

    public void setWorkDir(String workDir) {
        this.workDir = workDir;
    }

    public String getPrivateKey() {
        return privateKey;
    }

    public void setPrivateKey(String privateKey) {
        this.privateKey = privateKey;
    }

    public String getPrivateKeyPassword() {
        return privateKeyPassword;
    }

    public void setPrivateKeyPassword(String privateKeyPassword) {
        this.privateKeyPassword = privateKeyPassword;
    }

    public String getDomain() {
        return domain;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    @Bean(value = "sftpOssClient")
    public SftpOssClient sftpOssClient(){
        return new SftpOssClient(host,port,username,password,workDir,privateKey,privateKeyPassword);
    }
}
